<template>
  <div>
    <h2>插槽</h2>
    <InvestDel ref="InvestDelref">
        <template v-slot="data">
        <input type="button" value="删除" @click="Del(data.data)" />
      </template>
    </InvestDel>
  </div>
</template>

<script setup lang="ts">
  import  axios from 'axios';
import InvestDel from './InvestDel.vue'
  import {ref} from 'vue'
  const InvestDelref=ref()
  function Del(id: any) {
  if (confirm('确定要删除吗？')) {
    axios({
      url: 'http://localhost:57328/api/Invest/GetInvestDel',
      method: 'get',
      params: {
        Iid: id
      }
    })
      .then((res) => {
        console.log(res);
        if (res.data.data > 0) {
          alert('删除成功');
          InvestDelref.value.getlist();
        } else if (res.data.data == -1) {
          alert('投资人数大于0不能删除');
          return;
        }
      })
      .catch((err) => {
        console.log(err);
      });
  }
}
</script>

<style scoped>

</style>